home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.2 / StartingAmigaC / exam1.c next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.7 KB  |  112 lines

  1. /*
  2.    Example of opening a simple window on a custom screen - #1
  3.    written by Dan Schein April-88 for the 1988 AMIGA Developers Conference. 
  4.  
  5.    This example, and all those based on this example, were compiled and
  6.    tested with the Lattice V4.0 compiler.
  7. */
  8.  
  9. /*
  10.   Copyright (c) 1988 Commodore-Amiga, Inc.
  11.  
  12.   Executables based on this information may be used in software
  13.   for Commodore Amiga computers.  All other rights reserved.
  14.  
  15.   This information is provided "as is"; no warranties are made.
  16.   All use is at your own risk, and no liability or responsibility is assumed.
  17. */
  18.  
  19.  
  20. #include <exec/types.h>
  21. #include <intuition/intuition.h>
  22. #include <libraries/dos.h>
  23.  
  24. /*
  25.    Define the Version of the Amiga OS we want (require)
  26.  
  27.    Operating System Version Information
  28.  
  29.       0     Any version is OK
  30.       30    1.0 or higher
  31.       31    1.1 NTSC or Higher
  32.       32    1.1 PAL  or Higher
  33.       33    1.2 or higher
  34.       34    1.3 or higher
  35.  
  36. */
  37.  
  38. #define INTUITION_REV 0
  39.  
  40. struct NewWindow OurWindow =
  41. {
  42.    20, 20,                                   /* LeftEdge and TopEdge      */
  43.    300, 100,                                 /* Width and Height          */
  44.    0, 1,                                     /* DetailPen and BlockPen    */
  45.    NULL,                                     /* IDCMP Flags               */
  46.    ACTIVATE|SMART_REFRESH,                   /* Flags                     */
  47.    NULL, NULL,                               /* Gadget and Image pointers */
  48.    "A Simple Window",                        /* Window Title              */
  49.    NULL,                                     /* Screen pointer            */
  50.    NULL,                                     /* BitMap pointer            */
  51.    0, 0,                                     /* MinWidth and MinHeight    */
  52.    0, 0,                                     /* MaxWidth and MaxHeight    */
  53.    WBENCHSCREEN                              /* Type of window            */
  54. };
  55.  
  56. struct Window *window;
  57. struct IntuitionBase *IntuitionBase;
  58.  
  59. void main(), cleanexit(), cleanup();
  60.  
  61.  
  62.  
  63. void main()
  64. {
  65.    LONG i;
  66.               /* Method #1 of opening and error testing */
  67.  
  68.    IntuitionBase=(struct IntuitionBase*)
  69.       OpenLibrary("intuition.library",INTUITION_REV);
  70.  
  71.    if (IntuitionBase == NULL)
  72.    {
  73.       cleanexit ("Open Intuition Library failed!\n", RETURN_FAIL);
  74.    }
  75.  
  76.               /* Method #2 of opening and error testing */
  77.  
  78.    if((window=(struct Window *)OpenWindow(&OurWindow))==NULL)
  79.    {
  80.       cleanexit ("Open Window failed!\n", RETURN_FAIL);
  81.    }
  82.  
  83.    for(i=0; i<1000000; i++);
  84.  
  85.    cleanup();
  86.    exit (RETURN_OK);
  87. }
  88.  
  89.  
  90.  
  91. void cleanexit(s, err)
  92. UBYTE *s;
  93. int err;
  94. {
  95.    if(*s) printf(s);
  96.    cleanup();
  97.    exit(err);
  98. }
  99.  
  100. void cleanup()
  101. {
  102.    if(window)
  103.    {
  104.       CloseWindow(window);
  105.    }
  106.  
  107.    if(IntuitionBase)
  108.    {
  109.       CloseLibrary(IntuitionBase);
  110.    }
  111. }
  112.